package kt.hkit.androidcomplete01.chapter08;

import kr.hkit.androidcomplete01.R;
import android.app.Activity;
import android.os.Bundle;
import android.view.MotionEvent;
import android.view.View;
import android.widget.LinearLayout;
import android.widget.TextView;

public class HandlerAccessEx extends Activity {
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.ch08_handleraccessex);

		TextView tv = (TextView) findViewById(R.id.ch08_tv);
		setTouchHandler(tv);
	}

	private void setTouchHandler(final TextView tv) {
		LinearLayout linear = (LinearLayout) findViewById(R.id.linear);
		linear.setOnTouchListener(new View.OnTouchListener() {
			public boolean onTouch(View v, MotionEvent event) {
				if (event.getAction() == MotionEvent.ACTION_DOWN) {
					tv.setText("Touched");
					return true;
				}
				return false;
			}
		});
	}
}
